package com.twu.biblioteca;

import javax.swing.border.TitledBorder;
import java.security.PublicKey;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Hugo
 * Date: 31/01/13
 * Time: 23:19
 * To change this template use File | Settings | File Templates.
 */
public class Movie {
    private final int MaxRating = 10;
    private String Title;
    private int Year;
    private String Director;
    private int Rating; //-1 will be used for movies that are not rated

    public Movie(String Title, int Year, String Director, int Rating)
    {
        if(Rating>this.MaxRating)
        {
            throw new IllegalArgumentException(String.format("Rating must be a number between 0 and {0}", this.MaxRating));
        }
        this.Title = Title;
        this.Year = Year;
        this.Director = Director;
        this.Rating = Rating;
    }

    public Movie(String Title, int Year, String Director){
        this(Title, Year, Director, -1);
    }

    public String GetTitle()
    {
        return this.Title;
    }
    public int GetYear()
    {
        return this.Year;
    }
    public String GetDirector()
    {
        return this.Director;
    }
    public String GetRating()
    {
        if(this.Rating == -1)
        {
            return "N/A";
        }
        return String.format("%d/%d", this.Rating, this.MaxRating);
    }

    @Override public String toString()
    {
        return String.format("%s\t%d\t%s\t%s", this.GetTitle(), this.GetYear(), this.GetDirector(), this.GetRating());
    }


}
